package com.minyifang.wcspf.work.ui;

import com.minyifang.wcspf.common.base.BasePresenter;
import com.minyifang.wcspf.common.config.network.Constants;
import com.minyifang.wcspf.common.config.network.RetrofitHelper;
import com.minyifang.wcspf.work.model.HttpRespond;
import com.minyifang.wcspf.work.ui.home.model.SplashBean;

import org.json.JSONObject;

import io.reactivex.functions.Consumer;
import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by LuoYaWei on 2018/7/16.
 */
public class SplashPresenter extends BasePresenter<SplashView>{
    public void getSplashContent() {
        JSONObject jsonData = Constants.getJsonData(null, null);
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonData.toString());
        addTask(RetrofitHelper.getInstance().getService().getSplashContent(requestBody), new Consumer<HttpRespond<SplashBean>>() {
            @Override
            public void accept(HttpRespond<SplashBean> splashBeanHttpRespond) {
                getView().showSplashContent(splashBeanHttpRespond);
            }
        });
    }
}
